{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">应用管理</h3>
	<table class="layui-table">
		<tr>
			<td class="layui-td-gray">所属分组<font>*</font></td>
			<td><select id="category_id" name="category_id" xm-selected="{$detail ? $detail['category_id'] : ''}" xm-select="select2" xm-select-skin="default" xm-select-radio="true"></select></td>
		</tr>
		<tr>
			<td class="layui-td-gray">应用名称<font>*</font></td>
			<td>
				<input type="text" name="name" value="{$detail ? $detail['name'] : ''}" lay-reqText="请输入应用名称" placeholder="请输入应用名称" class="layui-input">
			</td>
			<td class="layui-td-gray">应用标识<font>*</font></td>
			<td>
				<input type="text" name="app_name" value="{$detail ? $detail['app_name'] : ''}" lay-reqText="请输入应用标识" placeholder="请输入应用标识" class="layui-input">
			</td>
			<td class="layui-td-gray">应用图标<font>*</font></td>
			<td>
				<input type="text" name="icon" value="{$detail ? $detail['icon'] : ''}" lay-reqText="请输入应用图标" placeholder="请输入应用图标" class="layui-input">
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">应用地址<font>*</font></td>
			<td>
				<input type="text" value="{$detail ? $detail['url'] : ''}" name="url" autocomplete="off" placeholder="请输入应用地址" lay-reqText="请输入应用地址" class="layui-input">
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">权重</td>
			<td>
				<input type="text" value="{$detail ? $detail['weigh'] : ''}" name="weigh" autocomplete="off" placeholder="请输入权重值" lay-reqText="请输入权重值" class="layui-input">
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">使用权限</td>
			<td>
				<input type="radio" name="is_use" value="0" title="全员" {if empty($detail) || ($detail && $detail['is_use'] == '0')}checked{/if}>
				<input type="radio" name="is_use" value="1" title="指定" {if $detail && $detail['is_use'] == '1'}checked{/if}>				
			</td>
			<td class="layui-td-gray">通知权限</td>
			<td>
				<input type="radio" name="is_notice" value="0" title="全员" {if $detail && $detail['is_notice'] == '0'}checked{/if}>
				<input type="radio" name="is_notice" value="1" title="指定" {if empty($detail) || ($detail && $detail['is_notice'] == '1')}checked{/if}>				
			</td>
			<td class="layui-td-gray">管理权限</td>
			<td>
				<input type="radio" name="is_admin" value="0" title="全员" {if $detail && $detail['is_admin'] == '0'}checked{/if}>
				<input type="radio" name="is_admin" value="1" title="指定" {if empty($detail) || ($detail && $detail['is_admin'] == '1')}checked{/if}>				
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">状态<font>*</font></td>
			<td>
				<input type="radio" name="status" value="normal" title="正常" {if empty($detail) || ($detail && $detail['status'] == 'normal')}checked{/if}>
				<input type="radio" name="status" value="hidden" title="隐藏" {if $detail && $detail['status'] == 'hidden'}checked{/if}>				
			</td>
		</tr>
	</table>
	<div class="pt-4">
		<input type="hidden" name="id" value="{$id}">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool', 'formSelects'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,formSelects=layui.formSelects;
		var selected_a = $('#category_id').attr('xm-selected');
		formSelects.data('select2', 'server', {
			url: '/xapply/group/select',
			keyword: selected_a
		});
		form.on('submit(webform)', function(data){
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					setTimeout(function () {
						parent.location.reload();
					}, 1000);					
				}
			}
			tool.post("/xapply/myapp/add", data.field, callback);
			return false;
		});
		//监听提交
		form.on('submit(webform)', function(data){
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					tool.sideClose(1000);
				}
			}
			tool.post("/xapply/myapp/add", data.field, callback);
			return false;
		});
	}

</script>
{/block}
<!-- /脚本 -->